<template>
  <div class="box">
    <div class="box_top">
      <div class="box_nav">
        <i class="icon iconfont icon-bianji"></i>宝塔区窑店考评信息
      </div>
      <!-- <div class="box_title flex">
        <div class="box_title_lf flex" @click="searchDateClick(1)">
          <div class="title_time_lf">{{ Query.startTime }}</div>
          <div class="title_time_lr">
            <i class="icon iconfont icon-bianji"></i>
          </div>
        </div>
        <div class="box_title_lr flex" @click="searchDateClick(2)">
          <div class="title_time_lf">{{ Query.endTime }}</div>
          <div class="title_time_lr">
            <i class="icon iconfont icon-bianji"></i>
          </div>
        </div>
        <div class="box_title_search">
          <div>查询</div>
        </div>
      </div> -->
      <div class="box_main_bd">
        <div class="box_main_echarts">
          <div id="main_map"></div>
        </div>
      </div>
    </div>
    <!-- 选择时间弹出框 -->
    <dateModel @message="canifmDateClick" @cancel="cancelDateClick" :time="timeVal" :dataState="dataStateVal"></dateModel>
  </div>
</template>
<script>
  let echarts = require("echarts");
  import taskApi from "../../requestApi/taskApi";
  import dateModel from "../../components/Module/dateModel";
  import {
    Toast
  } from "mint-ui";
  export default {
    components: {
      dateModel
    },
    data() {
      return {
        Query: {
          areaUserId: "请选择",
          endTime: "请选择"
        },
        // 日期
        timeIndex: 1,
        dataStateVal: false,
        timeVal: "请选择",
        colorLists: ["#DFB885", "#88CFC7", "#DF87CF", "#EF8484"],
        yLists: ["2", "3", "4", "5"],
        xLists: ["红旗党支部", "91-95分", "80-90分", "80分以下"]
      };
    },
    created: function () {},
    mounted() {
      let self = this;
      self.baseUserMessageDistributeFun();
      window.getAppgetUserToken = function (val) {
        self.baseUserInfoFun(val);
        self.listFun();
      };
      self.titleFun({
        title: "标准化数据"
      });
    },
    methods: {
      searchDateClick(i) {
        this.dataStateVal = true;
        this.timeIndex = i;
      },
      canifmDateClick(val) {
        let value = this.baseDateFun(val);
        let temp = new Date(val).getTime();
        if (this.timeIndex == 1) {
          this.Query.startTime = value;
        } else {
          this.Query.endTime = value;
        }
        this.dataStateVal = false;
      },
      cancelDateClick() {
        this.dataStateVal = false;
      },
      mapListsFun() {
        let self = this;
        let eComVisitChart = echarts.init(document.getElementById("main_map"));
        eComVisitChart.setOption({
          xAxis: {
            type: "category",
            data: self.xLists,
            axisLabel: {
              interval: 0,
              rotate: -35
            }
          },
          yAxis: {
            name: "(数量)",
            type: "value"
          },
          series: [{
            itemStyle: {
              normal: {
                color: function (params) {
                  return self.colorLists[params.dataIndex];
                },
                label: {
                  show: false
                }
              }
            },
            silent: true,
            data: self.yLists,
            type: "bar",
            barWidth: 25 //柱图宽度
          }]
        });
      },
      async listFun() {
        let self = this;
        let params = {
          id: this.$route.query.id
        };
        let res = await taskApi.GetApiWebmessageboardlist(params);
        if (res.statusCode == 200) {
          self.mapListsFun();
        } else {
          self.mapListsFun();
          Toast({
            message: res.statusMessage,
            position: "bottom"
          });
        }
      }
    },
    filters: {},
    watch: {},
    computed: {}
  };

</script>
<style scoped>
  .box_title_search {
    width: 1.44rem;
    font-size: 0.3733rem;
    color: #fff;
    line-height: 0.72rem;
    text-align: center;
    height: 0.72rem;
    background: rgba(255, 255, 255, 1);
    border-radius: 0.0533rem;
    background-color: #e7383e;
    margin-top: 0.32rem;
    margin-left: 0.32rem;
  }

  .box_nav i {
    font-size: 0.32rem;
    color: #000;
    margin-right: 0.1333rem;
  }

  .box_nav {
    height: 1.2rem;
    line-height: 1.2rem;
    background-color: #fff;
    font-size: 0.4267rem;
    color: #000;
    width: 100%;
    padding-left: 0.4rem;
    font-weight: 600;
  }

  .box_top {
    overflow: hidden;
  }

  /* 时间筛选 */
  .title_time_lf {
    width: 1.8667rem;
    height: 0.72rem;
    line-height: 0.72rem;
    padding-left: 0.32rem;
    font-size: 0.4rem;
    font-family: PingFang-SC-Medium;
    font-weight: 500;
    color: rgba(91, 98, 109, 1);
  }

  .title_time_lr {
    width: 0.9333rem;
    height: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  .title_time_lr::after {
    position: absolute;
    left: 0rem;
    width: 0.0267rem;
    height: 0.5067rem;
    background: rgba(120, 120, 120, 0.32);
    top: 0.1067rem;
    content: "";
  }

  .title_time_lr i {
    color: #8c96a6;
    font-size: 0.3467rem;
  }

  .box_title_lf {
    width: 2.8rem;
    height: 0.72rem;
    background: rgba(248, 248, 248, 1);
    border-radius: 0.0533rem;
    margin-left: 0.4267rem;
    margin-top: 0.32rem;
  }

  .box_title_lr::after {
    position: absolute;
    left: -0.5867rem;
    width: 0.3467rem;
    height: 0.0267rem;
    background: rgba(235, 46, 51, 1);
    top: 0.2933rem;
    content: "";
  }

  .box_title_lr {
    width: 2.8rem;
    height: 0.72rem;
    background: rgba(248, 248, 248, 1);
    border-radius: 0.0533rem;
    margin-left: 0.88rem;
    margin-top: 0.32rem;
    position: relative;
  }

  .box_title {
    width: 100%;
    min-height: 1.3333rem;
    background: rgba(255, 255, 255, 1);
    margin-top: 0.1867rem;
  }

  #main_map {
    width: 100%;
    height: 260px;
    overflow: hidden;
  }

  /* 时间筛选 */

  /* 图表 */
  #main_map_line {
    width: 100%;
    overflow: hidden;
    border: 1px solid red;
  }

  .box_main_echarts {
    width: calc(100% - 0.8rem);
    margin-left: 0.4rem;
    overflow: hidden;
    position: relative;
  }

  /* 图表 */
  .box_main_bd {
    width: 100%;
    background: rgba(255, 255, 255, 1);
    overflow: hidden;
    margin-top: 0.1867rem;
  }

  .box {
    background: #f6f6f6;
    overflow: hidden;
    width: 100%;
    height: 100vh;
    overflow-y: scroll;
  }

</style>
